EmaMobile.views.FirstPageView = Ext.extend( Ext.Panel,{

    layout : 'vbox',
    fullscreen : true,
    

    

    initComponent : function() {     


        this.toolbar = new Ext.Toolbar({
            title : 'Accueil',
        });

        this.icon1 = new Ext.Panel({
            html:'<div align=center><img src="img/campagne.png"/><p style="font-size:12px">Campagne</p></div>',
            margin: '0 30 0 30',
            hideAnimation:{type:'fade',duration: 200},
            showAnimation:{type:'fade',duration: 200},
            listeners:{
                afterrender:function(c){
                    c.el.on('tap',function(){
                         EmaMobile.views.firstPageView.icon1.hide();
                         setTimeout(function() {
                            EmaMobile.views.firstPageView.icon1.show();
                         },201);
                         
                                Ext.Ajax.request({
                                    url : EmaMobile.views.authentificationView.urlPlatforme+'/getEvaluationsWithTodo?contentType=xml',
                                    scope : this,
                                    success : function(response, opts) {                                   
                                            Ext.dispatch({
                                                 controller: EmaMobile.controllers.controller,
                                                 action: 'list-campagnes',
                                                 response: response.responseText,
                                                 updateCampagnes: EmaMobile.views.authentificationView.updateCampagne,
                                                 direction : 'left' 
                                             });
                                     },
                                     failure : function(response, opts) {
                                         
                                             var message = new Ext.MessageBox();
                                             message.show({
                                                 title: 'Information',
                                                 msg: '<div>Erreur de chargement</div>',
                                                 buttons: [{text:'OK',itemId:'ok'}],
                                                 fn : function(itemId){
                                                     EmaMobile.views.authentificationView.loginField.reset();
                                                     EmaMobile.views.authentificationView.passwordField.reset();
                                                 }
                                             });
                                             message.doComponentLayout();
                                             
                                              //console.log("ERROR : "+ response.responseText);
                                             
                                     }
                                });
                    });
                }
            }
            
        });

        this.icon2 = new Ext.Panel({
            html:'<div align=center><img src="img/resultat.png"/><p style="font-size:12px">Résultat</p></div>',
            margin: '0 30 0 30',
            hideAnimation:{type:'fade',duration: 200},
            showAnimation:{type:'fade',duration: 200},
            listeners:{
                afterrender:function(c){
                    c.el.on('tap',function(){
                         EmaMobile.views.firstPageView.icon2.hide();
                         setTimeout(function() {
                            EmaMobile.views.firstPageView.icon2.show();
                         },201);
                         Ext.dispatch({
                             controller: EmaMobile.controllers.controller,
                             action: 'affiche-resultat',                                       
                         });
                    });   
                }
            }
            
        });

        this.buttonsPanel = new Ext.Panel({
            baseCls : 'action-sheet-panel',
            margin: '30 0 0 0',
            layout : {
                type : 'hbox',
                align : 'center',
                pack : 'center',
            },
            height: 32,
            items: [this.icon1,this.icon2]
        });

        this.dockedItems = [ this.toolbar ],

        this.items = [ this.buttonsPanel ],


        
        EmaMobile.views.FirstPageView.superclass.initComponent.call(this);

        
    },
});